package org.csy.generic.test00.demo01.teacherWork.demo01;

import org.csy.generic.test00.demo01.myWork.Behavior;

import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;

/**
 * @author CSY
 * @date 2025 - 03 - 25
 */
public class People<P> {
    private P pet;

    public People(){}

    public People(P pet) {
        this.pet = pet;
    }

    public P getPet() {
        return pet;
    }

    public void setPet(P pet) {
        this.pet = pet;
    }

    public void shopping(){
        System.out.println("带宠物逛街");
        //注意：在编译时无法确定P具体是谁
        //解决一：强转
        //解决二：设置边界
        //解决三：反射
        if (pet instanceof Animal a){
            a.call();
        }

    }
}
